<?php
/*
 * 手机客户端 账户页面接口
 * 传入参数 
 * 2013-12-011
 */
include "inc/public_header.php";
include "func/user.php";				//用户信息处理函数

$reJson = array();//构建返回值

//获取用户信息
$uInfoArr = user_getInfoFromUUID();

if(!$uInfoArr){
	echo json_encode(array("success"=>"0","errCode"=>"0"));
	die;
}
$uid = $uInfoArr["uid"]; //用户信息主键

//$uid='10638';
//logo显示根路径
$SHOW_IMG_BASE_URL = "http://www.chinalaohu.com//modules/miniature.php?w=150&h=150&p=/uploads/zjl_ilogo/";

//默认头像
//$LOGO_DEFAULT_PATH = "http://www.chinalaohu.com/images/zjl/zjl_i_logo_t.jpg";
 $LOGO_DEFAULT_PATH = "http://www.chinalaohu.com/images/zjl/logo.png";

 $reJson["success"]="1";

 
 
 
 
$sql="select realname,e_auth,i_auth,m_auth from user_base where uid='".$uid."' ";
  $db->query($sql);

  $verify=array();
  
  while($db->next_record()){
  	if($db->f("realname")){
			$name = 1;
		}else {
			$name = 0;
		}
		$verify=array(
			"name"=>strval($name),
			"card"=>$db->f("i_auth"),
			"email"=>$db->f("e_auth")
			);
}

 $reJson["verify"]=$verify;

 $sql="select 
		a.mobile,a.realname,a.ustatus,b.ilogo_path,b.nickname,a.m_auth,a.e_auth,a.i_auth,a.sex,a.birthday,a.idtype,a.idnumber,a.email,
c.province,c.city,c.district,c.street,c.zipcode,d.cardno,b.xuexiao,b.xuehao,b.zhuanye,b.year
    from user_base a
		LEFT JOIN new_weituo_person b on a.uid=b.uid
		LEFT JOIN user_addresses c on a.uid=c.uid and set_default=1
		LEFT JOIN user_bank d on a.uid=d.uid 
    where a.uid ='".$uid."' ";
$db->query($sql);
$perfectInfo=array();
$isComplete ="0";
$isStudent='0';
while($db->next_record()){
	if($db->f("nickname")!=''&&$db->f("realname")!=''&&$db->f("birthday")!=''&&$db->f("email")!=''&&$db->f("zhuanye")!=''&&$db->f("xuehao")!=''&&$db->f("year")!=''&&$db->f("sex")!=''){
		$isComplete ="1";
	}
	if($db->f("xuexiao")){
		$isStudent='1';
	}
	if($db->f("nickname")){
		$nickName=$db->f("nickname");
	}else{
		$nickName="";
	}
	if($db->f("realname")){
		$realName=$db->f("realname");
	}else{
		$realName="";
	}
	if($db->f("sex")){
		$sex=$db->f("sex");
	}else{
		$sex="0";
	}
	if($db->f("birthday")){
		$birthday=$db->f("birthday");
	}else{
		$birthday="";
	}
	if($db->f("idnumber")){
		$cardNumber=$db->f("idnumber");
	}else{
		$cardNumber="";
	}
	if($db->f("email")){
		$email=$db->f("email");
	}else{
		$email="";
	}
	if($db->f("xuexiao")){
		$college=$db->f("xuexiao");
	}else{
		$college="";
	}
	if($db->f("zhuanye")){
		$major=$db->f("zhuanye");
	}else{
		$major="";
	}
	if($db->f("xuehao")){
		$studentId=$db->f("xuehao");
	}else{
		$studentId="";
	}
	if($db->f("year")){
		$entrance=$db->f("year");
	}else{
		$entrance="";
	}
	if($db->f("cardno")){
		$bank=$db->f("cardno");
	}else{
		$bank="";
	}
	if($db->f("ilogo_path")){
		$userIcon=$SHOW_IMG_BASE_URL.$db->f("ilogo_path");
	}else{
		$userIcon=$LOGO_DEFAULT_PATH;
	}
	$perfectInfo=array(
		"nickName"=>$nickName
		,"realName"=>$realName
		,"userIcon"=>$userIcon
		//,"userIcon"=>""
		,"sex"=>$sex
		,"birthday"=>$birthday
		,"cardList"=>array($db->f("idtype"))
		,"cardType"=>$db->f("idtype")
		,"cardNumber"=>$cardNumber
		,"email"=>$email
		,"address"=>$db->f("province").$db->f("city").$db->f("district").$db->f("street")
		,"bank"=>$bank
		,"college"=>$college
		,"major"=>$major
		,"studentId"=>$studentId
		,"entrance"=>$entrance	
		,"isStudent"=>$isStudent
	);

}
 $reJson["isComplete"]=$isComplete;
 $reJson["perfectInfo"]=$perfectInfo;
 
echo json_encode($reJson);

?>